package com.ptp.index;

import com.googlecode.cqengine.ConcurrentIndexedCollection;
import com.googlecode.cqengine.IndexedCollection;
import com.googlecode.cqengine.attribute.Attribute;
import com.googlecode.cqengine.attribute.SimpleAttribute;
import com.googlecode.cqengine.index.navigable.NavigableIndex;
import com.googlecode.cqengine.query.option.QueryOptions;
import com.ptp.push.MessageInfo;

/**
 * 
 * @author nnli
 *
 */
public class MessageIndex {

	private static IndexedCollection<MessageInfo> INFOINDEX = new ConcurrentIndexedCollection<MessageInfo>();
	
	private static Attribute<MessageInfo, String> INFOID = new SimpleAttribute<MessageInfo, String>("userId") {
		@Override
		public String getValue(MessageInfo info, QueryOptions queryOptions) {
			return info.getUserId();
		}
	};
	
	static{
		INFOINDEX.addIndex(NavigableIndex.onAttribute(INFOID));
	}
	
	public static IndexedCollection<MessageInfo> getMessageIndex(){
		return INFOINDEX;
	}
}
